﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="ManageUsers.aspx.cs" Inherits="TsWeb.Followers.ManageUsers" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="LeftContent" runat="server">
    <div>
        <ul>
            <div class="accordion" id="accordion2">
                <div class="accordion-group">
                    <div class="accordion-heading">
                        <li class="nav-header" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
                            Gestión de usuarios</li>
                    </div>
                </div>
            </div>
        </ul>
    </div>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Path="~/Scripts/jquery-1.9.1.js" />
            <asp:ScriptReference Path="~/Scripts/bootstrap.min.js" />
        </Scripts>
    </asp:ScriptManager>
    <p>
    </p>
    <asp:UpdatePanel ID="UpdatePanel2" runat="server">
        <Triggers>
            <asp:PostBackTrigger ControlID="UserButton" />
        </Triggers>
        <ContentTemplate>
        
                <p>
            <asp:GridView ID="UserAccounts" runat="server" AutoGenerateColumns="False" CssClass="table table-hover table-striped"
                GridLines="None" OnRowCommand="UserAccounts_RowCommand">
                <Columns>
                    <asp:BoundField DataField="UserName" HeaderText="Usuario" />
                    <asp:BoundField DataField="Email" HeaderText="Email" />
                    <asp:CheckBoxField DataField="IsLockedOut" HeaderText="¿Bloqueado?" />
                    <asp:CheckBoxField DataField="IsOnline" HeaderText="¿En línea?" />
                    <asp:ButtonField ButtonType="Link" CommandName="EditCommand" Text="Editar" />
                    <asp:ButtonField ButtonType="Link" CommandName="DeleteCommand" Text="Eliminar" />
                </Columns>
            </asp:GridView>
            </p>
            <p>
        <asp:Button ID="ButtonCreateUser" runat="server" Text="Nuevo usuario" OnClick="ButtonCreateUser_Click"
                CssClass="btn-success right pull-right" />
                </p>
            
            <p>
            </p>
            <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
                aria-hidden="true">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        ×</button>
                    <h3 id="myModalLabel">
                        Gestión de usuarios
                    </h3>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal">
                    
                        <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserNameTxt" CssClass="control-label">Usuario:</asp:Label>
                       
                            <asp:TextBox ID="UserNameTxt" runat="server" CssClass="input-large" ReadOnly="true"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserNameTxt"
                                CssClass="failureNotification" ErrorMessage="User Name is required." ToolTip="User Name is required."
                                ValidationGroup="CreateUsersUserValidationGroup">*</asp:RequiredFieldValidator>

                    
                    <asp:Label ID="NameLabel" runat="server" AssociatedControlID="NameTxt">Nombre:</asp:Label>
                    <asp:TextBox ID="NameTxt" runat="server" CssClass="input-large"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="NameRequired" runat="server" ControlToValidate="NameTxt"
                        CssClass="failureNotification" ErrorMessage="El nombre no puede ser vacio." ToolTip="El nombre no puede ser vacio."
                        ValidationGroup="CreateUsersUserValidationGroup">*</asp:RequiredFieldValidator>
                    <asp:Label ID="SurnameLabel" runat="server" AssociatedControlID="SurnameTxt">Apellido:</asp:Label>
                    <asp:TextBox ID="SurnameTxt" runat="server" CssClass="input-large"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="SurnameTxt"
                        CssClass="failureNotification" ErrorMessage="El apellido no puede ser vacio."
                        ToolTip="El apellido no puede ser vacio." ValidationGroup="CreateUsersUserValidationGroup">*</asp:RequiredFieldValidator>
                    <asp:Label ID="EmailLabel" runat="server" AssociatedControlID="EmailTxt">E-mail:</asp:Label>
                    <asp:TextBox ID="EmailTxt" runat="server" CssClass="input-large"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="EmailRequired" runat="server" ControlToValidate="EmailTxt"
                        CssClass="failureNotification" ErrorMessage="E-mail is required." ToolTip="E-mail is required."
                        ValidationGroup="CreateUsersUserValidationGroup">
                        *<asp:RegularExpressionValidator ID="regexEmailValid" runat="server" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                            CssClass="failureNotification" ControlToValidate="EmailTxt" ErrorMessage="Email Invalido"
                            ToolTip="Email invalido" ValidationGroup="CreateUsersUserValidationGroup"></asp:RegularExpressionValidator></asp:RequiredFieldValidator>
                    <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="PasswordTxt">Contraseña:</asp:Label>
                    <asp:TextBox ID="PasswordTxt" runat="server" CssClass="input-large" TextMode="Password"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="PasswordTxt"
                        CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Password is required."
                        ValidationGroup="CreateUsersUserValidationGroup">*</asp:RequiredFieldValidator>
                    <asp:Label ID="ConfirmPasswordLabel" runat="server" AssociatedControlID="ConfirmPasswordTxt">Confirmar contraseña:</asp:Label>
                    <asp:TextBox ID="ConfirmPasswordTxt" runat="server" CssClass="input-large" TextMode="Password"></asp:TextBox>
                    <asp:RequiredFieldValidator ControlToValidate="ConfirmPasswordTxt" CssClass="failureNotification"
                        Display="Dynamic" ErrorMessage="Confirm Password is required." ID="ConfirmPasswordRequired"
                        runat="server" ToolTip="Confirm Password is required." ValidationGroup="CreateUsersUserValidationGroup">*</asp:RequiredFieldValidator>
                    <asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="PasswordTxt"
                        ControlToValidate="ConfirmPasswordTxt" CssClass="failureNotification" Display="Dynamic"
                        ErrorMessage="The Password and Confirmation Password must match." ValidationGroup="CreateUsersUserValidationGroup">*</asp:CompareValidator>
                    <asp:Label ID="RolLabel" runat="server" AssociatedControlID="UsersRoleList">Roles:</asp:Label>
                    <asp:Repeater ID="UsersRoleList" runat="server">
                        <ItemTemplate>
                            <asp:CheckBox runat="server" ID="RoleCheckBox" AutoPostBack="false" Checked="true"
                                Text='<%# Container.DataItem %>' />
                        </ItemTemplate>
                    </asp:Repeater>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="EmailTxt"
                        CssClass="failureNotification" ErrorMessage="E-mail is required." ToolTip="E-mail is required."
                        ValidationGroup="CreateUsersUserValidationGroup">*</asp:RequiredFieldValidator>
                    <span class="failureNotification">
                        <asp:Literal ID="ErrorMessage" runat="server"></asp:Literal>
                    </span>
                    <asp:ValidationSummary ID="CreateUsersSummary" runat="server" CssClass="failureNotification"
                        ValidationGroup="CreateUsersUserValidationGroup" />
                                              
                    </form>
                </div>
                <div class="modal-footer">
                    <asp:Button ID="UserButton" runat="server" Text="Actualizar usuario" CssClass="btn btn-primary"
                        ValidationGroup="CreateUsersUserValidationGroup" OnClick="UpdateUserButton_Click" />
                </div>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
